<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  div {
    float: left;
    margin: 10px;
  }

  #div1 {
    width: 50px;
    height: 50px;
    background: red;
  }

  #div2 {
    width: 250px;
    height: 180px;
    background: #CCC;
    display: none;
  }
</style>

<body>

  <div id="div1"></div>
  <div id="div2"></div>


  <script>
    let div1 = document.getElementById("div1")
    let div2 = document.getElementById("div2")
    let timeOut = null
    div1.onmouseover = function () {
      div2.style.display = "block"
    }
    div1.onmouseout = function () {
      clearTimeout(timeOut)
      timeOut = setTimeout(() => {
        div2.style.display = "none"
      }, 1500);
    }
    div2.onmouseover = function () {
      clearTimeout(timeOut)
    }
    div2.onmouseout = function () {
      timeOut = setTimeout(() => {
        div2.style.display = "none"
      }, 1500);
    }
  </script>

</body>

</html>